﻿Public Class DueReport

    Private ms As Base.Entities.Moira()
    Private ty As Base.Entities.ServiceType()
    Private dues As Base.SortableCollection(Of Base.Entities.Dues)

    Private Sub DueReport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ty = My.Connector.Client.ServiceType
        ms = My.Connector.Client.Moires
        CheckedListBox1.DataSource = ms
        CheckedListBox1.DisplayMember = "Name"
        CheckedListBox2.DataSource = ty
        CheckedListBox2.DisplayMember = "Name"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim selectedMoires As New List(Of Base.Entities.Moira)
        Dim selectedTypes As New List(Of Base.Entities.ServiceType)
        For Each i In CheckedListBox1.SelectedItems
            selectedMoires.Add(i)
        Next

        For Each i In CheckedListBox2.SelectedItems
            selectedTypes.Add(i)
        Next

        dues = My.Connector.Client.Staff(selectedMoires.ToArray, selectedTypes.ToArray)

        Me.Cursor = Cursors.WaitCursor
        Me.SuspendLayout()
        DataGridView1.DataSource = dues
        DataGridView1.Columns("id").Visible = False
        Me.ResumeLayout()
        Me.Cursor = Cursors.Arrow

    End Sub

    Private Sub DataGridView1_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        If e.RowIndex > -1 Then
            Dim x As Base.Entities.Dues = DataGridView1.Rows.Item(e.RowIndex).DataBoundItem
            MsgBox(x.id)
        End If
    End Sub

    Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If e.RowIndex = -1 Then
            'sorting
            SortDataGrid(DataGridView1, e.ColumnIndex)
            'DataGridView1.Columns(0).HeaderCell().SortGlyphDirection = SortOrder.Descending
        End If
    End Sub

End Class